package org.mclll.xwangplugin.log;

import com.google.common.collect.Maps;

import java.util.Map;
import java.util.logging.Logger;

/**
 * @author: geduo
 * @date: 2023/9/22 14:50
 */
public class LoggerFactory {

    public static Logger LOGGER;
    private static final Map<Class<?>, LogUtil> LOG_DATA = Maps.newHashMap();

    public static void init(Logger logger) {
        LOGGER = logger;
    }

    public static LogUtil get(Class<?> clazz) {
        LogUtil logUtil = LOG_DATA.get(clazz);
        if (logUtil == null) {
            try {
                logUtil = (LogUtil) clazz.getDeclaredConstructor().newInstance();
            } catch (Exception ignore) {
            }
            LOG_DATA.put(clazz, logUtil);
        }
        return logUtil;
    }
}
